package com.harmonyos.samples.view;

import com.intellij.openapi.ui.DialogWrapper;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.awt.*;

public class RemindMessage extends DialogWrapper {

    private String latestVersion;

    public RemindMessage(String latestVersion) {
        super(true);
        this.latestVersion = latestVersion;
        setTitle("插件更新");
        setOKButtonText("接受");
        setCancelButtonText("忽略");
        init();
    }


    @Override
    protected @Nullable JComponent createCenterPanel() {
        JPanel jPanel = new JPanel();
        jPanel.setPreferredSize(new Dimension(300, 80));
        SpringLayout springLayout = new SpringLayout();
        jPanel.setLayout(springLayout);

        JTextPane jTextPane = new JTextPane();
        jTextPane.setPreferredSize(new Dimension(300, 40));
        jTextPane.setEnabled(false);
        jTextPane.setText(String.format("您有一个HarmonyOS Sample组件市场-%s-Alpha的更新版本可供下载。", latestVersion));
        springLayout.putConstraint(SpringLayout.HORIZONTAL_CENTER, jTextPane, 0, SpringLayout.HORIZONTAL_CENTER, jPanel);
        springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, jTextPane, 0, SpringLayout.VERTICAL_CENTER, jPanel);
        jPanel.add(jTextPane);

        return jPanel;
    }
}
